//
//  OPUser.h
//  OPFramework
//
//  Created by malcom on 7/12/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "OPBaseObject.h"

#define OPUserProp_Avatar					@"html_avatar"
#define OPUserProp_LastPostTime				@"user_lastpost_time"
#define OPUserProp_LastVisitTime			@"user_lastvisit"
#define OPUserProp_RegistrationDate			@"user_regdate"
#define OPUserProp_BirthdayDate				@"user_birthday"
#define OPUserProp_Signature				@"user_sig"
#define OPUserProp_NumberOfPosts			@"user_posts"
#define OPUserProp_UserID					@"user_id"
#define OPUserProp_Username					@"username"
#define OPUserProp_MessengerAIM				@"user_aim"
#define OPUserProp_MessengerMSN				@"user_msnm"
#define OPUserProp_MessengerJabber			@"user_jabber"
#define OPUserProp_MessengerYIM				@"user_yim"
#define OPUserProp_MessengerICQ				@"user_icq"
#define OPUserProp_Website					@"user_website"
#define OPUserProp_Rank						@"user_rank"
#define OPUserProp_UserType					@"user_type"
#define OPUserProp_Lang						@"user_lang"
#define OPUserProp_Posts					@"user_posts"

/*!
    @enum		OPUser_Type
    @abstract   This is the available values for OPUserProp_UserType properties
    @constant   OPUser_Type_Normal		normal user
	@constant	OPUser_Type_Inactive	inactive user
	@constant	OPUser_Type_Ignore		(not defined)
	@constant	OPUser_Type_Founder		board founder
*/

typedef enum OPUser_Type {
	OPUser_Type_Normal			= 0,
	OPUser_Type_Inactive		= 1,
	OPUser_Type_Ignore			= 2,
	OPUser_Type_Founder			= 3
} OPUser_Type;

@interface OPUser : OPBaseObject {
	NSString				*p_username;
	int						 p_userid;
	
	NSData					*p_avatar;
	NSDate					*p_lastPostDate;
	NSDate					*p_lastVisitDate;
	NSDate					*p_registrationDate;
	NSDate					*p_birthdayDate;
	NSString				*p_signature;
	NSNumber				*p_numberOfPosts;
	
	NSString				*p_messenger_aim;
	NSString				*p_messenger_msn;
	NSString				*p_messenger_yim;
	NSString				*p_messenger_jabber;
	NSString				*p_messenger_icq;
	
	NSString				*p_website;
	NSString				*p_lang;
	NSNumber				*p_userType;
	NSNumber				*p_userRank;
}

@property (readonly) NSString		*p_username;
@property (readonly) int			 p_userid;

@property (readonly) NSData		*p_avatar;
@property (readonly) NSDate			*p_lastPostDate;
@property (readonly) NSDate			*p_lastVisitDate;
@property (readonly) NSDate			*p_registrationDate;
@property (readonly) NSDate			*p_birthdayDate;
@property (readonly) NSString		*p_signature;
@property (readonly) NSNumber		*p_numberOfPosts;

@property (readonly) NSString		*p_messenger_aim;
@property (readonly) NSString		*p_messenger_msn;
@property (readonly) NSString		*p_messenger_yim;
@property (readonly) NSString		*p_messenger_jabber;
@property (readonly) NSString		*p_messenger_icq;

@property (readonly) NSString		*p_website;
@property (readonly) NSString		*p_lang;
@property (readonly) NSNumber		*p_userType;
@property (readonly) NSNumber		*p_userRank;

- (id) initUserID:(NSNumber *) _uid fromBoard:(OPBoard *) _board;

/*!
    @method     initWithUsername:andID:ofBoard:
    @abstract   This method allows you to instantiate a new OPUser class with only basics parameters.
	@discussion	You should not instantiate this class directly. Simply call <i>-getUserMemberFromID:usingCache:</i> method<br/>
				from OPMembersCache class related to the board (the method will make a new OPUser class with only an userid and username.<br/>
				If you pass usingCache: NO it will load the entire profile informations (using sync request method).<br/>
	@param		_username username
	@param		_id the unique id of the user
	@param		_board the related board
*/
- (id) initWithUsername:(NSString *) _username andID:(NSNumber *) _id ofBoard:(OPBoard *) _board;

/*!
    @method     initWithShortSummaryDataResponseFromPostLoad:ofBoard:
    @abstract   This method will create a new OPUser class by loading basic profile informations.
    @discussion You should not call this method directly. It's used when you load some posts from a topic (both to create an user or refresh it's informations).
	@param		_data the dictionary with informations to load or refresh (see topic_infos->'topic_messages' keys of getTopicsMessages in OPAPI Server Library  
	@param		_board the related board
*/

- (id) initWithShortSummaryDataResponseFromPostLoad:(NSDictionary*) _data ofBoard:(OPBoard *) _board;

/*!
    @method     refreshCompleteProfile
    @abstract   This method allows to refresh user profile
    @discussion The method call refresh user profile data using sync download
	@result		return YES if update works fine
*/

- (BOOL) refreshCompleteProfile;

- (int) sendEmailWithSubject:(NSString *) _subj andText:(NSString *) _text;
- (BOOL) sendPrivateMessageWithSubject:(NSString *) _subj andText:(NSString *) _text;

#pragma mark PRIVATE METHODS
- (void) _updateProfileWithData:(NSDictionary *) _data;
- (void) _loadShortSummaryFromData:(NSDictionary *) _data;
- (void) _setAvatarImageFromFilename:(NSString *) _filename;

@end
